package org.zachary.prosocialbehaviorservice.infrastructure.repository;

import jakarta.persistence.EntityNotFoundException;
import org.springframework.stereotype.Repository;
import org.zachary.prosocialbehaviorservice.domain.aggregate_model.activity.Activity;
import org.zachary.prosocialbehaviorservice.domain.repository.ActivityRepository;

import java.util.List;
import java.util.Optional;

@Repository
public class JpaActivityRepository implements ActivityRepository {
    private final SpringDataActivityRepository jpaRepo;
    public JpaActivityRepository(SpringDataActivityRepository jpaRepo) {
        this.jpaRepo = jpaRepo;
    }

    @Override
    public void save(Activity activity) {
        jpaRepo.save(activity);
    }



    @Override
    public Optional<Activity> findById(Integer id) {
        return jpaRepo.findById(id);
    }

    @Override
    public void modify(Integer activityId, Activity activity) {
        activity.setId(activityId);
        jpaRepo.save(activity);
    }

    @Override
    public void deleteById(Integer id) {
        jpaRepo.deleteById(id);
    }

    @Override
    public List<Activity> findAllActivities() {
        return jpaRepo.findAll();
    }
}
